package com.etmvc.core;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import com.et.ar.Converter;

public class DateConverter implements Converter {
        @Override
        public Object convert(Object value) {
        	if (value == null) {
				return null;
			}
            try {
            	String v = value.toString();
            	String fmt ;
            	if (v.length()<=10) {
					fmt = "yyyy-MM-dd";
				}else {
					fmt = "yyyy-MM-dd HH:mm:ss";
				}
				return new SimpleDateFormat(fmt).parse(value.toString());
			} catch (ParseException e) {
				e.printStackTrace();
			}
			return null;
        }
    	
}